package com.lindenvalley.ch.adapters;

import java.util.Calendar;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.ArrayAdapter;

import com.lindenvalley.ch.content.Week;
import com.lindenvalley.ch.content.Weeks;

public class AbstractWeekTaskAdapter extends ArrayAdapter<Week> {
	
	protected Context mContext;
	protected int mResource;
	protected Weeks mWeeks;
	protected LayoutInflater inflater;
	protected Calendar mCalendar;
	protected final String KALENDER_TEXT = "KW ";
	
	public AbstractWeekTaskAdapter(Context context, int textViewResourceId, Weeks weeks){
		super(context, textViewResourceId);
		mContext = context;
		mResource = textViewResourceId;
		mWeeks = weeks;
		inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		mCalendar = Calendar.getInstance();
	}
	
	@Override
	public int getCount() {
		return mWeeks != null ? mWeeks.getWeekCount() : 0;
	}
		
	@Override
	public Week getItem (int position){
//		Log.i("", ">>>>>>>>> getItem()");
		try{
			return mWeeks != null ? mWeeks.getWeek(position) : null;
		} catch (IndexOutOfBoundsException ex){
			return null;
		}
	}
	
	public void setData(Weeks weeks){
		mWeeks = weeks;
	}

}
